package com.eet.juc.cas;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * CAS深入学习Demo
 *
 * @author zheng.zhang
 */
public class CasDemo {

    public static void main(String[] args) {
        AtomicInteger atomicInteger = new AtomicInteger(2020);

        // 如果达到期望就更新,否则就不变
        atomicInteger.compareAndSet(2020, 2021);
        System.out.println(atomicInteger.get());
    }
}
